// Problem: 
// Contest: 
// URL: 
// Memory Limit: 
// Time Limit: 
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
int n,ans;
vector<int> v;
//bool f0=0;
void dfs(int j,int sum,int k)
{
	if(j==k)return ;
	if(sum>v[k])
	{
		ans=min(sum,ans);
		return ;
	}
	dfs(j+1,sum+v[j+1],k);
	dfs(j+1,sum,k);
}
signed main()
{
	int t=1;
	cin>>t;
	while(t--)
	{
		cin>>n;
		int jie=INT_MAX;
		v=vector<int> (n+1);
		for(int i=1;i<=n;i++)cin>>v[i];
		sort(v.begin()+1,v.end());
		bool f=0;
		for(int i=3;i<=n;i++)
		{
			ans=INT_MAX;
			dfs(1,v[1],i);
			dfs(1,0,i);
			if(ans!=INT_MAX)jie=min(ans+v[i],jie);
			if(f)break;
		}
		if(jie==INT_MAX)cout<<-1<<endl;
		else cout<<jie<<endl;
	}
	return 0;
}
